function minganci (str, arr) {
  // console.log(arr, str)
  for (let i = 0; i < arr.length; i++) {
    let reg = new RegExp(arr[i], 'g')
    let strRep = ''
    for (let j = 0; j < arr[i].length; j++) {
      strRep += '*'
    }
    str = str.replace(reg, strRep)
  }
  return str
}
console.log(minganci('想要轻生,have sexy ,sexy boy', ['轻生', 'sex']))